/*
 * CameraDevice.cpp
 *
 *  Created on: 2018年10月3日
 *      Author: zhengboyuan
 */
#include "stdafx.h"
#include "CameraDevice.h"


CameraDevice::CameraDevice():
	m_camera(),
	m_flowCount(),
	m_sink()
{
}

CameraDevice::~CameraDevice()
{
	
}


void CameraDevice::setSink(PersonFlowSink* sink)
{
	comn::AutoCritSec lock(m_cs);
	m_sink = sink;
}

bool CameraDevice::getCount(PersonFlowCount& flowCount)
{
	comn::AutoCritSec lock(m_cs);
	flowCount = m_flowCount;
	return true;
}

std::string CameraDevice::getId()
{
	return m_camera.id;
}

bool CameraDevice::getCamera(Camera& camera)
{
	comn::AutoCritSec lock(m_cs);
	camera = m_camera;
	return true;
}

void CameraDevice::fireDeviceStatus(int connected)
{
	if (!m_sink)
	{
		return;
	}

	m_sink->onDeviceStatus(m_camera.id, connected);
}

void CameraDevice::fireFlowCount(const PersonFlowCount& flowCount)
{
	if (!m_sink)
	{
		return;
	}

	m_sink->onFlowCount(m_camera.id, flowCount);
}

void CameraDevice::setConnected(bool connected)
{
	// 
}

void CameraDevice::setCount(const PersonFlowCount& flowCount)
{
	comn::AutoCritSec lock(m_cs);
	m_flowCount = flowCount;
}